package org.NooLab.itexx.app.controller;



import org.NooLab.itexx.ITexxWindowIntf;
import org.NooLab.itexx.app.gui.definition.ITexxWindowGuiIntf;
import org.NooLab.itexx.retrieval.RequestPreProcessing;
import org.NooLab.itexx.retrieval.RequestPreProcessingIntf;
import org.NooLab.itexx.retrieval.RetrievalEngine;
import org.NooLab.itexx.retrieval.SearchRequestHandler;
import org.NooLab.itexx.stuctures.GuiPersistenceData;
import org.NooLab.itexx.stuctures.RequestFocusContext;





public class ItexxModelController {

	
	
	ITexxWindowIntf texxWindowApp;
	ITexxWindowGuiIntf appGui;

	SearchRequestHandler searchRequest ;// = new SearchRequestHandler();
	RetrievalEngine retrievalEngine ;
	private RequestFocusContext requestFocusContext;

	private boolean fullRequest ;

	private boolean fileContext;
	private RequestPreProcessingIntf requestPreProcessing;
	private int responsiveness=1;
	private boolean userBreak=false;
	
	
	// ========================================================================
	public ItexxModelController(ITexxWindowIntf app) {
	
		texxWindowApp = app;
		appGui = texxWindowApp.getWindowGui();
		// app.getAppCommons().setModelController(this);
		
		requestFocusContext = new RequestFocusContext(app);
		
		requestPreProcessing = new RequestPreProcessing( app ) ;
		
	}
	// ========================================================================


	// ========================================================================
	
	
	/**
	 * called e.g. in  DjBrowserHost::update(), 
	 * or upon transmission of data via the clipboard
	 * in main app::setClipboardString
	 * 
	 * this here is just a facade
	 * @return 
	 */
	public GuiPersistenceData updateFocusDataFromGui() {
		
		GuiPersistenceData guiData;
		guiData = requestFocusContext.updateFocusDataFromGui();
		
		// it is now also in the GuiPersistence object !!! 
		// GuiPersistenceData guiData = requestFocusContext.getGuiPersistence().getGuiData();
		return guiData;
	}



	public SearchRequestHandler getSearchRequest() {
		
		if (searchRequest==null){
			
			searchRequest = new SearchRequestHandler(texxWindowApp);
			
		}else{
			if (searchRequest.isDispatcherIsRunning()==false){
				// searchRequest.startDispatcher();
			}	
		}
		
		return searchRequest;
	}


	public void setRequestFocusContext(RequestFocusContext requestFocusContext) {
		this.requestFocusContext = requestFocusContext;
	}


	public RequestFocusContext getRequestFocusContext() {
		return requestFocusContext;
	}


	public RequestPreProcessingIntf getRequestPreProcessing() {
		return requestPreProcessing;
	}


	public void setRequestPreProcessing(RequestPreProcessingIntf requestPreProcessing) {
		this.requestPreProcessing = requestPreProcessing;
	}


	public void setFileContext(boolean fileContext) {
		this.fileContext = fileContext;
	}


	public boolean isFileContext() {
		return fileContext;
	}


	public void setFullRequest(boolean fullRequest) {
		this.fullRequest = fullRequest;
	}


	public boolean isFullRequest() {
		return fullRequest;
	}


	public ITexxWindowIntf getTexxWindowApp() {
		return texxWindowApp;
	}


	public void setResponsiveness(int flag) {
		// 
		responsiveness = flag;
	}


	public int getResponsiveness() {
		return responsiveness;
	}


	public void clearPanelList(int remainingItems) {
		// 
		
	}


	public void setUserBreak(boolean flag) {
		// 
		userBreak = flag;
	}


	public boolean isUserBreak() {
		return userBreak;
	}
	
	
	
	
}
